﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class Admin_ZHJBXXB_Manage : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (!IsPostBack)
        {
            PopulateDrop();
        }
        txtUserID.Attributes.Add("ReadOnly", "true");
    }

    // 绑定下拉框
    public void PopulateDrop()
    {
        drpAccountStatus.PopulateFromEnum<ZHJBXX.statusAccount>();
        drpAccountStatus.Items.Insert(0, new ListItem("请选择", "0"));
        drpCardStatus.PopulateFromEnum<ZHJBXX.statusCard>();
        drpCardStatus.Items.Insert(0, new ListItem("请选择", "0"));
    }

    // 获得用户名
    public string GetUserName(object UserID)
    {
        string Return = "暂无资料";
        Client objClient = Client.Get(DongDong.Common.Misc.ConvertToInt(UserID));
        if (objClient != null)
        {
            Return = "<a target='_blank' href='../../Admin/Client/Add.aspx?UserID=" + objClient.ID + "'>" + objClient.Username + "</a>";
        }
        return Return;
    }

    // 获得资金流向记录
    public string GetAccountDetail(object AccountNo)
    {
        string Return = "暂无资料";
        Client objClient = Client.Get(DongDong.Common.Misc.ConvertToInt(AccountNo));
        if (objClient != null)
        {
            Return = "<a target='_blank' href='../../Admin/ZJLXJL/Add.aspx?UserID=" + objClient.ID + "'>" + objClient.Username + "</a>";
        }
        return Return;
    }

    protected void Pager_PreRender(object sender, EventArgs e)
    {
        if (lvDate.Items.Count == 0)
            PopulateZHJBXX();
    }

    // 查询
    public void PopulateZHJBXX()
    {                                                    
        lvDate.DataSource = ZHJBXX.GetAllByConditon(DongDong.Common.Misc.ConvertToInt(hdlUserID.Value),DongDong.Common.Misc.ConvertToInt(drpAccountStatus.SelectedValue),txtAccountNo.Text, txtYuEFrom.Text, txtYuETo.Text,txtDJJEFrom.Text, txtDJJETo.Text,txtAddTimeFrom.Text,txtAddTimeTo.Text,DongDong.Common.Misc.ConvertToInt(drpCardStatus.SelectedValue));
        lvDate.DataBind();
    }

    protected void lvDate_ItemDeleting(object sender, ListViewDeleteEventArgs e)
    {
        int KeyID = DongDong.Common.Misc.ConvertToInt(lvDate.DataKeys[e.ItemIndex].Value);
        ZHJBXX.BadDelete(KeyID);
        lvDate.EditIndex = -1;
        PopulateZHJBXX();
    }
    protected void btnSearch_Click(object sender, EventArgs e)
    {
        PopulateZHJBXX();
    }
}